<div class="row">
			<div class="panel-default panel">
				<div class="panel-heading">
					权限管理(请输入需要更改权限用户的邮箱或昵称)
				</div>
				<div class="panel-body">
						<%=form_tag(search_roles_path,class: "navbar-form form-search active") do%>
						<div class=" form-group ">
							<input class="form-control" name="q" type="text" value="<%= params[:q]%>" placeholder="搜索用户" />
						</div>
						<%end%>
						<span style="margin-left: 14px">搜索结果共 <%= @users.present? ?  @users.results.total : '0' %>条</span>
						<br>
						<HR>
						<strong style="color: grey"> 用户管理</strong>
						<div class="tabbable">
							<ul class="nav nav-tabs">
								<li class="active"><a href="#search" data-toggle="tab">搜索用户</a></li>
								<li class=""><a href="#alluser" data-toggle="tab">所有用户 </a></li>
							</ul>
							<div class="tab-content">
								<div class="tab-pane" id="search">

									<%if @users.present?%>
										<div class="result">
											<% if @users.present?%>
												<%= form_tag(action: "create",method: :post)do %>
													<ul class="list-group">
														<li class="form-inline  list-group-item" >
															<input type="checkbox"  id="check_all" class="check1" onclick="clickss()" name="all" value="all"/>
															&nbsp;&nbsp;全选

															<div class="btn btn-group">
																<%= select_tag("add_all",options_for_select(ApplicationController::ROLE_SET.to_a),prompt:'添加分组到',class: "selectpicker")%>
															</div>
														</li>
														<% @users.records.each_with_hit do |item,hit|%>
															<% if item.class.name.downcase.eql?("user")%>

																<li class=" list-group-item form-inline">
																	<input type="checkbox" class="checkbox "  name="users_id[]" value="<%= item.id%>" name="checks"/>


																	<div class="" style="display: inline-block;vertical-align: middle">
																		<div class=" media " style="display: inline">
																			<div class="media-heading media-left">
																				<%=gravatar_for(item,size: "60")%>
																			</div>
																			<div class="media-body media-middle" style="width: auto">
																				<%= item.name%>
																			</div>
																		</div>
																	</div>

																	<div class="btn btn-group pull-right" style="display: inline">
																		<%= select_tag("user[#{item.id}]",options_for_select(ApplicationController::ROLE_SET.to_a) ,prompt:'添加分组到',class: "selectpicker")%>
																	</div>
																</li>
															<%end%>
														<%end%>
													</ul>
													<%= submit_tag("确定",class: "btn-default btn btn-block ")%>
													<!--<button class="btn-default btn btn-block" onclick="senddata()">确定</button>-->
												<%end%>
											<%end%>
										</div>
									<%end%>

								</div>

								<div class="tab-pane" id="alluser">
									<%= form_tag(action: "create",method: :post)do %>
										<ul class="list-group">
											<li class="form-inline  list-group-item" >
												<input type="checkbox"  id="check_all" class="check1" onclick="clickss()" name="all" value="all"/>
												&nbsp;&nbsp;全选

												<div class="btn btn-group">
													<%= select_tag("add_all",options_for_select(ApplicationController::ROLE_SET.to_a),prompt:'添加分组到',class: "selectpicker")%>
												</div>
											</li>
											<%@all_users.each do |item|%>
												<% if item.class.name.downcase.eql?("user")%>
													<li class=" list-group-item form-inline">
														<input type="checkbox" class="checkbox "  name="users_id[]" value="<%= item.id%>" name="checks"/>


														<div class="" style="display: inline-block;vertical-align: middle">
															<div class=" media " style="display: inline">
																<div class="media-heading media-left">
																	<%=gravatar_for(item,size: "60")%>
																</div>
																<div class="media-body media-middle" style="width: auto">
																	<%= item.name%>
																</div>
															</div>
														</div>

														<div class="btn btn-group pull-right" style="display: inline">
															<%= select_tag("user[#{item.id}]",options_for_select(ApplicationController::ROLE_SET.to_a) ,prompt:'添加分组到',class: "selectpicker")%>
														</div>
													</li>
												<%end%>
											<%end%>
										</ul>
										<%= submit_tag("确定",class: "btn-default btn btn-block ")%>
									<%end%>
								</div>
							</div>
						</div>
						<br>
						<br>
				</div>
			</div>
</div>

<script type="text/javascript">

	var  toggle = true;

	function clickss(){
		if (toggle) {
			$(" .checkbox").each(function (i, item) {
				item.checked = true;
			})
		}
		else{
			$(" .checkbox").each(function (i, item) {
				item.checked = false;
			})
		}
		toggle=!toggle;
	}

</script>